// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "../DeclareDelegate.h"
#include "InteractionInteractorComponent.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class ANIMSAMPLE_API UInteractionInteractorComponent : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UInteractionInteractorComponent();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

	UFUNCTION(BlueprintCallable)
	virtual void RaycastInterestActor(FHitResult& HitResult, float DeltaTime);
	UFUNCTION(BlueprintCallable)
	AActor* GetInterestActor();
	UFUNCTION(BlueprintCallable)
	void ClientInteractorStart(AActor* Interactor, AActor* Participant);
	UFUNCTION(BlueprintCallable)
	void ClientInteractorStop(AActor* Interactor, AActor* Participant);
	UFUNCTION(BlueprintCallable, Server, Reliable)
	void ServerInteractorStart(AActor* Interactor, AActor* Participant);
	UFUNCTION(BlueprintCallable, Server, Reliable)
	void ServerInteractorStop(AActor* Interactor, AActor* Participant);

	UPROPERTY()
	FNotifyWithTwoActor NotifyInteractorStartScript;
	UPROPERTY()
	FNotifyWithTwoActor NotifyInteractorStopScript;
	
protected:
	UPROPERTY(BlueprintReadWrite, EditDefaultsOnly)
	int32 InteractiveDistance = 2000;
	UPROPERTY(BlueprintReadWrite, VisibleDefaultsOnly)
	AActor* InterestActor = nullptr;
	UPROPERTY(BlueprintReadWrite, VisibleDefaultsOnly)
	bool OnInterest = false;
	UPROPERTY()
	FString StartScriptFunctionName{"InteractionStart"};
	UPROPERTY()
	FString StopScriptFunctionName{"InteractionStop"};
};
